package com.example.guiguihomemedical.mapper;

import com.example.guiguihomemedical.entity.Record;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RecordMapper {
        // 添加
        @Insert("INSERT INTO record (idcard, name, nation, residence, detailedresidence, time, doctorid, phone,sex) " +
                "VALUES (#{idcard}, #{name}, #{nation}, #{residence}, #{detailedresidence}, #{time}, #{doctorid}, #{phone},#{sex})")
        void insertRecord(Record record);
        //修改
//        @Update("UPDATE record SET name = #{name}, nation = #{nation}, residence = #{residence}, " +
//                "detailedresidence = #{detailedresidence}, time = #{time}, organization = #{organization}, " +
//                "doctorid = #{doctorid}, phone = #{phone} WHERE idcard = #{idcard}")
        void updateRecord(Record record);
        @Update("UPDATE record SET type = #{type} WHERE idcard = #{idCard}")
        void updateRecordType(String idCard,String type);
        //修改
        @Update("UPDATE record SET name = #{name}, nation = #{nation}, " +
                "detailedresidence = #{detailedresidence}, sex = #{sex}, " +
                "phone = #{phone} WHERE idcard = #{idcard}")
        void updateRecord_h(Record record);
        //删除
        @Delete("DELETE FROM record WHERE idcard = #{idcard}")
        void deleteRecordById(String idcard);
        //查询单个
        @Select("SELECT * FROM record WHERE idcard = #{idcard}")
        Record findByIdcard(@Param("idcard") String idcard);
        // 查询所有记录
        @Select("SELECT * FROM record")
        List<Record> findAllRecords();
        //模糊查询
        List<Record> recordList(String query);
}
